package com.cb.web.wasf.sample.web;

import com.cb.web.wasf.Request;
import com.cb.web.wasf.State;
import com.cb.web.wasf.View;
import com.cb.web.wasf.View.JspView;

/**
 * @author CBO
 */
public class ConfirmDialogState extends State {

    private ConfirmDialogStateHandler confirmDialogStateHandler;
    private String confirmationMessage;

    public ConfirmDialogState(ConfirmDialogStateHandler confirmDialogStateHandler, String confirmationMessage) {
        this.confirmDialogStateHandler = confirmDialogStateHandler;
        this.confirmationMessage = confirmationMessage;
    }

    public static interface ConfirmDialogStateHandler {

        State confirm();

        State cancel();
    }

    public String getConfirmationMessage() {
        return confirmationMessage;
    }

    @Override
    public View getView() {
        return new JspView(this, "/WEB-INF/jsp/confirmDialog.jsp");
    }

    public State confirm(Request request) {
        return confirmDialogStateHandler.confirm();
    }

    public State cancel(Request request) {
        return confirmDialogStateHandler.cancel();
    }
}
